package com.future.mayi.activity;

import android.content.Context;
import android.view.View;

/**
 * Created by 周大虎 on 2016/12/2.
 */

public abstract class BasePage {
    public Context context;
    public View view;

    public BasePage(Context context) {
        this.context = context;
        view = initLayout();
        initView();
        initListener();
        initDates();
    }

    // 返回当前界面通过xml布局构建的view
    public View getRootView() {
        return view;
    }


    protected View findViewById(int viewId) {
        if (view != null) {
            return view.findViewById(viewId);
        } else {
            return null;
        }
    }


    public View getView() {
        return view;
    }

    protected View setContentView(int resource) {
        if (view == null) {
            view = View.inflate(context, resource, null);
        }
        return view;
    }

    protected abstract View initLayout();

    protected abstract void initView();

    protected abstract void initDates();

    protected abstract void initListener();
}
